import 'dart:ui';

import 'package:get/get.dart';
import 'package:part_time_job_pro/common/cache/app_box.dart';

class Local {
  static String offer = 'offer'; //招聘
  static String find = 'find'; //找人才
  static String message = 'home'; //消息
  static String mine = 'mine'; //我的
  static String languageSetting = 'languageSet'; //多语言设置
  static String followerSystemLanguage = 'followerSystemLanguage'; //跟随系统语言
  static String simplifiedChinese = 'simplifiedChinese'; //简体中文
  static String traditionalChinese = 'traditionalChinese'; //繁體中文
  static String english = 'English';
  //主题相关
  static String followerSystemTheme = 'followerSystemTheme';
  static String lightMode = 'lightMode';
  static String darkMode = 'darkMode';


  //获取语言
  static Locale? getLocale() {
    Locale? appLocale;
    switch (AppBox.shared.language) {
      case 0: //跟隨系統
        appLocale = Get.deviceLocale;
        break;
      case 1: //简体中文
        appLocale = const Locale('zh', 'CN');
        break;
      case 2: //繁体中文
        appLocale = const Locale('zh', 'HK');
        break;
      case 3: //English
        appLocale = const Locale('en', 'US');
        break;
      default:
        appLocale = Get.deviceLocale;
        break;
    }
    return appLocale;
  }

  ///切换语言
  static void changeLanguage(int languageIndex) {
    Locale? appLocale;
    switch (languageIndex) {
      case 0: //跟隨系統
        appLocale = Get.deviceLocale;
        break;
      case 1: //简体中文
        appLocale = const Locale('zh', 'CN');
        break;
      case 2: //繁体中文
        appLocale = const Locale('zh', 'HK');
        break;
      case 3: //English
        appLocale = const Locale('en', 'US');
        break;
      default:
        appLocale = Get.deviceLocale;
        break;
    }
    //保存到本地
    AppBox.shared.language = languageIndex;
    Get.updateLocale(appLocale!);
  }
}
